#include "learner/logistic_regression.h"
#include "matrices/matrix.h"
#include "sample/sample.h"
#include "sample/sample_set.h"
#include "comm/functors.hpp"

#include <algorithm>

using namespace nymphaea;
using namespace nymphaea::learner;

LogisticRegression::~LogisticRegression()
{
}

const std::vector<double> LogisticRegression::classify(const sample::Sample& sample) const
{
	matrices::Matrix weight_for_each_category((*mpCoeffMatrix) * sample);
	weight_for_each_category.transform(comm::Exp());
	double sum = 1.0F + weight_for_each_category.sum();
	weight_for_each_category.transform(std::bind2nd(std::divides<double>(), sum));
	return weight_for_each_category.row_to_vector(0);
}

int LogisticRegression::train(const storage::SampleSet& sample_set)
{
	return 0;
}
